package edu.uwm.universitydb.swing;

import java.util.List;

import edu.uwm.universitydb.tests.PerformanceTest;
import edu.uwm.universitydb.tests.PerformanceTests;

public class PerformanceTableModel extends DataTableModel {

	public PerformanceTableModel(PerformanceTests tests) {
		super(_colNames, _colTypes);
		_tests = tests;
	}

	@Override
	public int getRowCount() {
		return _tests.getTests().size();
	}

	@Override
	public Object getValueAt(int row, int col) {
		List<PerformanceTest> test = _tests.getTests();
		switch (col) {
		case 0:
			return test.get(row).getName();
		case 1:
			return test.get(row).getBeforeTime();
		case 2:
			return test.get(row).getAfterTime();
		default:
			return "Error";
		}
	}

	private static final long serialVersionUID = 3639658600260875476L;

	private static final String[] _colNames = new String[] { "Test Name", "Before Index Time (ms)", "After Index Time (ms)"};
	private static final Class<?>[] _colTypes = new Class<?>[] { String.class, Long.class, Long.class };

	private final PerformanceTests _tests;

}
